package leetcode.秋招.小马智行;


import java.util.Scanner;
import java.util.Stack;

public class Main1 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int count = 0;
        Stack<Character> stack = new Stack<>();
        char[] chars = str.toCharArray();
        if (chars.length < 4) {
            System.out.println(0);
            return;
        }
        StringBuilder builder = new StringBuilder();
        builder.append(str, 0, 3);
        stack.push(chars[0]);
        stack.push(chars[1]);
        stack.push(chars[2]);
        for (int i = 3; i < chars.length; i++) {
            char ch = chars[i];
            builder.append(ch);
            if ("pony".equals(builder.toString())) {
                count++;
                builder = new StringBuilder();
                while (!stack.isEmpty() && builder.length() < 3) {
                    builder.append(stack.pop());
                }
                builder.reverse();
            } else {
                if (builder.length() >= 4) {
                    stack.push(builder.charAt(0));
                    builder.deleteCharAt(0);
                }
            }
        }
        System.out.println(count);
    }

}
